package ui.swing.spinner;

import java.awt.BorderLayout;

import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerListModel;
import javax.swing.SpinnerModel;
import javax.swing.border.EmptyBorder;

public class SpinnerDemoList extends JFrame{

	private static final long serialVersionUID = 2631551969103228143L;

	public SpinnerDemoList() {
		super("Spinner Demo (List)");
		JPanel p = new JPanel();
		p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
		p.setBorder(new EmptyBorder(10, 10, 10, 10));
		
		p.add(new JLabel("Select Item:"));
		SpinnerModel model = new SpinnerListModel (new String[]{
			"AK", "AL", "AR", "AZ", "CA",
			"CO", "CT", "DE", "FL", "GA",
			"HI", "IA", "ID", "IL", "IN",
			"KS", "KY", "LA", "MA", "MD",
			"ME", "MI", "MN", "MO", "MS",
			"MT", "NC", "ND", "NE", "NH",
			"NJ", "NM", "NV", "NY", "OH",
			"OK", "OR", "PA", "RI", "SC",
			"SD", "TN", "TX", "UT", "VA",
			"VT", "WA", "WV", "WI", "WY"
		});
		JSpinner spn = new JSpinner(model);
		p.add(spn);

		getContentPane().add(p, BorderLayout.NORTH);
		setSize(400,75);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);
	}
	
	public static void main(String[] args) {
		new SpinnerDemoList();
	}
}
